]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
cleanup: Don't assume hasOwnProperty() method on objects
authorFlorian Müllner <fmuellner@gnome.org>
Sat, 29 Jun 2019 23:05:27 +0000 (01:05 +0200)
committerFlorian Müllner <fmuellner@gnome.org>
Thu, 12 Sep 2019 21:18:27 +0000 (23:18 +0200)
Since ES5, it is possible to create objects with no prototype at all:

    let foo = Object.create(null);

Those object won't have any builtin properties like hasOwnProperty(),
which is why eslint added a corresponding rule to its default rule set.

While this isn't an issue that affects our code, there's no harm in fol-
lowing the recommendation and call the method through Object.prototype.

https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/716

js/ui/layout.js
js/ui/sessionMode.js

index 85bbd24c22abbf9372fcc6d6946cf833939af092..bfe19bfcb58029604bdb569eaf12ca2afeba31a1 100644 (file)
@@ -861,7 +861,7 @@ var LayoutManager = GObject.registerClass({
         // We can't use Params.parse here because we want to drop
         // the extra values like ancestorData.actor
         for (let prop in defaultParams) {
-            if (!params.hasOwnProperty(prop))
+            if (!Object.prototype.hasOwnProperty.call(params, prop))
                 params[prop] = ancestorData[prop];
         }
 
index 583780111a364a0811a80faf4e758ae66951209a..55a422f3d5a2899b96350b0d58438fa236b8702b 100644 (file)
@@ -111,7 +111,7 @@ function _loadMode(file, info) {
     let suffix = name.indexOf('.json');
     let modeName = suffix == -1 ? name : name.slice(name, suffix);
 
-    if (_modes.hasOwnProperty(modeName))
+    if (Object.prototype.hasOwnProperty.call(_modes, modeName))
         return;
 
     let fileContent, success_, newMode;